package 第十一章_网络编程.第十一章_网络编程_服务器与客户端_UDP下载;

import java.io.IOException;
import java.net.*;

public class service {
    public static void main(String[] args) {
        String info="this is a str.节点";
        byte[] bytes=info.getBytes();
        try {
            DatagramPacket dp=new DatagramPacket(
                    bytes,
                    0,
                    bytes.length,
                    InetAddress.getByName("127.0.0.1"),
                    8000); //发送8000  发送到socket(8000端口） socket（9000端口）在发送给流  流在发送给client

            DatagramSocket socket=new DatagramSocket(9000);//接收
            socket.send(dp);
            socket.close();
        } catch (UnknownHostException | SocketException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
